// imports
import { NgModule, enableProdMode } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { RouterModule, Routes, CanLoad } from "@angular/router";
import { HttpModule } from "@angular/http";
import { SocketModule } from "socket";
import { CmHttpModule } from "CmHttp";
import { UtilsModule } from "utils";
import { StockModule } from "./stock/stock.module";
import { QuoteModule } from './quote/quote.module';
import { UserModule } from "./user/user.module";
import { AboutModule } from "./about/about.module";
import { SearchModule } from "./search/search.module";
import { QuoteTableModule } from "quote";
import { WatchlistMiniModule } from "./watchlist-mini/watchlist-mini.module";
// import { LiveModule } from "./live/live.module";
import { CommentsModule } from "./comments/comments.module";
import { MethodModule } from "./method/method.module";
import { AuthGuardModule, AuthGuardService } from "./auth-guard";

import { AppComponent } from "./app/app.component";
import { WatchlistComponent } from "./watchlist/watchlist.component";
import { TradeComponent } from "./trade/trade.component";
import { StockComponent } from "stock";
import { QuoteComponent } from "quote";
import { CommentsComponent } from "./comments/comments.component";
import { MethodComponent } from "./method/method.component";

import { CommentsService } from "./comments/comments.service";
// Routes: 按照精确的路由在前面，通用的路由在后面进行顺序匹配
// router reference: https://angular.cn/docs/ts/latest/guide/router.html
const appRoutes: Routes = [
  {
    path: "stock",
    component: StockComponent
  }, {
    path: "quote",
    component: QuoteComponent
  }, {
    path: "method",
    // component: MethodComponent
    component: MethodComponent
  }, {
    path: "comments",
    component: CommentsComponent
  }, {
    path: "",
    redirectTo: "comments",
    pathMatch: "full"
  }, {
    path: "**",
    redirectTo: "comments",
    pathMatch: "full"
  }
];

// Application NgModule
@NgModule({
  imports: [
    AuthGuardModule,
    BrowserAnimationsModule,
    HttpModule,
    QuoteModule,
    StockModule,
    UserModule,
    AboutModule,
    BrowserModule,
    CmHttpModule,
    SocketModule,
    UtilsModule,
    SearchModule,
    QuoteTableModule,
    WatchlistMiniModule,
    CommentsModule,
    MethodModule,
    RouterModule.forRoot(appRoutes)
  ],
  providers: [
    { provide: Window, useValue: window },
    { provide: Document, useValue: document },
    CommentsService
  ],
  declarations: [
    AppComponent,
    WatchlistComponent,
    TradeComponent
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }